﻿using AutoMapper;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MyMES.Domain.zyy;
using MyMES.Error;
using MyMES.Writer.API.Application.CommendHandlers.BOMs;
using MyMES.Writer.API.Application.Commends.BOMs;

namespace MyMES.Writer.API.Controllers.BOMS
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BOMController : ControllerBase
    {
        private readonly IMediator mediator;

        public BOMController(IMediator  mediator)
        {
            this.mediator = mediator;
        }
        [HttpPost]
        public async Task<APIResult<BOM>> AddBOM(AddBomCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }
        [HttpPut]
        public async Task<APIResult<BOM>> UpdateBOM (UpdateBOMCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }
    }
}
